package com.cipe.cmrs.model;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import com.cipe.cmrs.util.DateUtil2;
import com.cipe.cmrs.util.Util;

/**
 * <p>
 * Pojo mapping TABLE dbo.DonorAward
 * </p>
 * 
 * <p>
 * Generated at Sat Dec 03 14:39:42 PKT 2011
 * </p>
 * 
 * @author Incepio
 * 
 */
@Entity
@Table(name = "donoraward")
@NamedQueries({ @NamedQuery(name = "getDonorawardByDonorawardNumberOrByDonor", query = " FROM Donoraward da where da.donorAwardNumber = ? or da.donor = ?") })
@SuppressWarnings("serial")
public class Donoraward extends BaseAuditEntity {

	@Transient
	String prc;
	@Transient
	String message;
	/**
	 * Attribute allocatedAmount.
	 */
	@Transient
	private BigDecimal allocatedAmount;
	/**
	 * Attribute attachment.
	 */
	@Basic
	@Column(name = "attachment")
	private String attachment;
	/**
	 * Attribute attachmentContentType.
	 */
	@Basic
	@Column(name = "attachmentcontenttype", length = 100)
	private String attachmentContentType;
	/**
	 * Attribute attachmentName.
	 */
	@Basic
	@Column(name = "attachmentname", length = 100)
	private String attachmentName;
	/**
	 * List of Cipeproject
	 */
	@OneToMany(mappedBy = "donoraward")
	private List<Cipeproject> cipeprojects = null;
	/**
	 * Attribute city.
	 */
	@Transient
	private String city;
	/**
	 * Attribute country
	 */
	@Transient
	private Country country;
	@Basic
	@Column(name = "directfunds")
	private BigDecimal directFunds;
	@Basic
	@Column(name = "indirectfunds")
	private BigDecimal indirectFunds;
	/**
	 * Attribute donor
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "donorid")
	private Donor donor;
	/**
	 * List of Donorawarcontact
	 */
	/*
	 * FIXME @OneToMany(mappedBy = "donoraward") private List<Donorawarcontact>
	 * donorawarcontacts = null;
	 */
	/**
	 * Attribute donorAwardDesc.
	 */
	@Basic
	@Column(name = "donorawarddesc", length = 500)
	private String donorAwardDesc;
	/**
	 * List of Donorawardmodification
	 */
	@OneToMany(mappedBy = "donoraward", cascade = { CascadeType.MERGE, CascadeType.REMOVE })
	private List<Donorawardmodification> donorawardmodifications = null;
	/**
	 * Attribute donorAwardNumber.
	 */
	@Basic
	@Column(name = "donorawardnumber", length = 50, unique = true)
	private String donorAwardNumber;
	/**
	 * List of Donorawardreportingdocument
	 */
	/*
	 * FIXME @OneToMany(mappedBy = "donoraward") private
	 * List<Donorawardreportingdocument> donorawardreportingdocuments = null;
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "donorawardstatusid")
	private Donorawardstatus donorawardstatus;

	/**
	 * Attribute donorawardtype
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "donorawardtypeid")
	private Donorawardtype donorawardtype;
	/**
	 * Attribute endDate.
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "enddate")
	private Date endDate;
	/**
	 * Attribute obligatedAmount.
	 */
	@Basic
	@Column(name = "obligedamount")
	private BigDecimal obligatedAmount;
	/**
	 * Attribute reportingAddress.
	 */
	@Transient
	private String reportingAddress;
	/**
	 * Attribute reportingAddress1.
	 */
	@Transient
	private String reportingAddress1;
	/**
	 * Attribute startDate.
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "startdate")
	private Date startDate;

    @Transient
    private String prevStartDate = "";
    @Transient
    private String prevEndDate = "";
    @Transient
    private Integer prevStatusId;
    @Transient
    private BigDecimal prevDirectFunds = BigDecimal.ZERO;
    @Transient
    private BigDecimal prevIndirectFunds = BigDecimal.ZERO;
    
	/**
	 * Attribute state.
	 */
	public String getFullDonorawardNumber() {
		String outcome = Util.concate(new String[] { this.donorAwardNumber != null ? this.donorAwardNumber : "",
				this.donor.getDonorName() != null ? this.donor.getDonorName() : "", this.startDate != null ? DateUtil2.INSTANCE.formatDate(new Timestamp(this.startDate.getTime())) : "",
				this.endDate != null ? DateUtil2.INSTANCE.formatDate(new Timestamp(this.endDate.getTime())) : "", this.fiscalyear != null ? this.fiscalyear.toString() : "",
				this.directFunds != null ? this.directFunds.toPlainString() : "", }, " | ");
		return outcome.length() > 110 ? outcome.substring(0, 109) : outcome;
	}

	@Transient
	private String state;
	/**
	 * Attribute statusCode.
	 */
	@Transient
	private Integer statusCode;
	/**
	 * Attribute statusOverrideComments.
	 */
	@Transient
	private String statusOverrideComments;
	/**
	 * Attribute statusOverrideDate.
	 */
	@Transient
	private Timestamp statusOverrideDate;
	/**
	 * Attribute statusOverrideFlag.
	 */
	@Transient
	private String statusOverrideFlag;
	/**
	 * Attribute statusOverrideUser.
	 */
	@Transient
	private Integer statusOverrideUser;
	/**
	 * Attribute memonotes.
	 */
	private String memonotes;
	/**
	 * Attribute fiscalyear.
	 */
	private Integer fiscalyear;

	@Transient
	private String modificationDocumentLocation;

	/**
	 * @return allocatedAmount
	 */
	public BigDecimal getAllocatedAmount() {
		return allocatedAmount;
	}

	/**
	 * @return attachment
	 */
	public String getAttachment() {
		return attachment;
	}

	/**
	 * @return attachmentContentType
	 */
	public String getAttachmentContentType() {
		return attachmentContentType;
	}

	/**
	 * @return attachmentName
	 */
	public String getAttachmentName() {
		return attachmentName;
	}

	/**
	 * Get the list of Cipeproject
	 */
	public List<Cipeproject> getCipeprojects() {
		return this.cipeprojects;
	}

	/**
	 * @return city
	 */
	public String getCity() {
		return city;
	}

	/**
	 * get country
	 */
	public Country getCountry() {
		return this.country;
	}

	/**
	 * @return the directFunds
	 */
	public BigDecimal getDirectFunds() {
		return directFunds;
	}

	/**
	 * get donor
	 */
	public Donor getDonor() {
		return this.donor;
	}

	/**
	 * Get the list of Donorawarcontact
	 */
	/*
	 * FIXME public List<Donorawarcontact> getDonorawarcontacts() { return
	 * this.donorawarcontacts; }
	 */
	/**
	 * @return donorAwardDesc
	 */
	public String getDonorAwardDesc() {
		return donorAwardDesc;
	}

	/**
	 * Get the list of Donorawardmodification
	 */
	public List<Donorawardmodification> getDonorawardmodifications() {
		return this.donorawardmodifications;
	}

	/**
	 * @return donorAwardNumber
	 */
	public String getDonorAwardNumber() {
		return donorAwardNumber;
	}

	/**
	 * Get the list of Donorawardreportingdocument
	 */
	/*
	 * public List<Donorawardreportingdocument>
	 * getDonorawardreportingdocuments() { return
	 * this.donorawardreportingdocuments; }
	 */
	/**
	 * @return the donorawardstatus
	 */
	public Donorawardstatus getDonorawardstatus() {
		return donorawardstatus;
	}

	/**
	 * get donorawardtype
	 */
	public Donorawardtype getDonorawardtype() {
		return this.donorawardtype;
	}

	/**
	 * @return endDate
	 */
	public Date getEndDate() {
		return endDate;
	}

	public Integer getFiscalyear() {
		return fiscalyear;
	}

	/**
	 * @return the indirectFunds
	 */
	public BigDecimal getIndirectFunds() {
		return indirectFunds;
	}

	public String getMemonotes() {
		return memonotes;
	}

	/**
	 * @return obligatedAmount
	 */
	public BigDecimal getObligatedAmount() {
		return obligatedAmount;
	}

	/**
	 * @return reportingAddress
	 */
	public String getReportingAddress() {
		return reportingAddress;
	}

	/**
	 * @return reportingAddress1
	 */
	public String getReportingAddress1() {
		return reportingAddress1;
	}

	/**
	 * @return startDate
	 */
	public Date getStartDate() {
		return startDate;
	}

	/**
	 * @return state
	 */
	public String getState() {
		return state;
	}

	/**
	 * @return statusCode
	 */
	public Integer getStatusCode() {
		return statusCode;
	}

	/**
	 * @return statusOverrideComments
	 */
	public String getStatusOverrideComments() {
		return statusOverrideComments;
	}

	/**
	 * @return statusOverrideDate
	 */
	public Timestamp getStatusOverrideDate() {
		return statusOverrideDate;
	}

	/**
	 * @return statusOverrideFlag
	 */
	public String getStatusOverrideFlag() {
		return statusOverrideFlag;
	}

	/**
	 * @return statusOverrideUser
	 */
	public Integer getStatusOverrideUser() {
		return statusOverrideUser;
	}

	/**
	 * @param allocatedAmount
	 *            new value for allocatedAmount
	 */
	public void setAllocatedAmount(BigDecimal allocatedAmount) {
		this.allocatedAmount = allocatedAmount;
	}

	/**
	 * @param attachment
	 *            new value for attachment
	 */
	public void setAttachment(String attachment) {
		this.attachment = attachment;
	}

	/**
	 * @param attachmentContentType
	 *            new value for attachmentContentType
	 */
	public void setAttachmentContentType(String attachmentContentType) {
		this.attachmentContentType = attachmentContentType;
	}

	/**
	 * @param attachmentName
	 *            new value for attachmentName
	 */
	public void setAttachmentName(String attachmentName) {
		this.attachmentName = attachmentName;
	}

	/**
	 * Set the list of Cipeproject
	 */
	public void setCipeprojects(List<Cipeproject> cipeprojects) {
		this.cipeprojects = cipeprojects;
	}

	/**
	 * @param city
	 *            new value for city
	 */
	public void setCity(String city) {
		this.city = city;
	}

	/**
	 * set country
	 */
	public void setCountry(Country country) {
		this.country = country;
	}

	/**
	 * @param directFunds
	 *            the directFunds to set
	 */
	public void setDirectFunds(BigDecimal directFunds) {
		this.directFunds = directFunds;
	}

	/**
	 * set donor
	 */
	public void setDonor(Donor donor) {
		this.donor = donor;
	}

	/**
	 * Set the list of Donorawarcontact
	 */
	/*
	 * FIXME public void setDonorawarcontacts(List<Donorawarcontact>
	 * donorawarcontacts) { this.donorawarcontacts = donorawarcontacts; }
	 */
	/**
	 * @param donorAwardDesc
	 *            new value for donorAwardDesc
	 */
	public void setDonorAwardDesc(String donorAwardDesc) {
		this.donorAwardDesc = donorAwardDesc;
	}

	/**
	 * Set the list of Donorawardmodification
	 */
	public void setDonorawardmodifications(List<Donorawardmodification> donorawardmodifications) {
		this.donorawardmodifications = donorawardmodifications;
	}

	/**
	 * @param donorAwardNumber
	 *            new value for donorAwardNumber
	 */
	public void setDonorAwardNumber(String donorAwardNumber) {
		this.donorAwardNumber = donorAwardNumber;
	}

	/**
	 * Set the list of Donorawardreportingdocument
	 */
	/*
	 * public void
	 * setDonorawardreportingdocuments(List<Donorawardreportingdocument>
	 * donorawardreportingdocuments) { this.donorawardreportingdocuments =
	 * donorawardreportingdocuments; }
	 */
	/**
	 * @param donorawardstatus
	 *            the donorawardstatus to set
	 */
	public void setDonorawardstatus(Donorawardstatus donorawardstatus) {
		this.donorawardstatus = donorawardstatus;
	}

	/**
	 * set donorawardtype
	 */
	public void setDonorawardtype(Donorawardtype donorawardtype) {
		this.donorawardtype = donorawardtype;
	}

	/**
	 * @param endDate
	 *            new value for endDate
	 */
	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public void setFiscalyear(Integer fiscalyear) {
		this.fiscalyear = fiscalyear;
	}

	/**
	 * @param indirectFunds
	 *            the indirectFunds to set
	 */
	public void setIndirectFunds(BigDecimal indirectFunds) {
		this.indirectFunds = indirectFunds;
	}

	public void setMemonotes(String memonotes) {
		this.memonotes = memonotes;
	}

	/**
	 * @param obligatedAmount
	 *            new value for obligatedAmount
	 */
	public void setObligatedAmount(BigDecimal obligatedAmount) {
		this.obligatedAmount = obligatedAmount;
	}

	/**
	 * @param reportingAddress
	 *            new value for reportingAddress
	 */
	public void setReportingAddress(String reportingAddress) {
		this.reportingAddress = reportingAddress;
	}

	/**
	 * @param reportingAddress1
	 *            new value for reportingAddress1
	 */
	public void setReportingAddress1(String reportingAddress1) {
		this.reportingAddress1 = reportingAddress1;
	}

	/**
	 * @param startDate
	 *            new value for startDate
	 */
	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	/**
	 * @param state
	 *            new value for state
	 */
	public void setState(String state) {
		this.state = state;
	}

	/**
	 * @param statusCode
	 *            new value for statusCode
	 */
	public void setStatusCode(Integer statusCode) {
		this.statusCode = statusCode;
	}

	/**
	 * @param statusOverrideComments
	 *            new value for statusOverrideComments
	 */
	public void setStatusOverrideComments(String statusOverrideComments) {
		this.statusOverrideComments = statusOverrideComments;
	}

	/**
	 * @param statusOverrideDate
	 *            new value for statusOverrideDate
	 */
	public void setStatusOverrideDate(Timestamp statusOverrideDate) {
		this.statusOverrideDate = statusOverrideDate;
	}

	/**
	 * @param statusOverrideFlag
	 *            new value for statusOverrideFlag
	 */
	public void setStatusOverrideFlag(String statusOverrideFlag) {
		this.statusOverrideFlag = statusOverrideFlag;
	}

	/**
	 * @param statusOverrideUser
	 *            new value for statusOverrideUser
	 */
	public void setStatusOverrideUser(Integer statusOverrideUser) {
		this.statusOverrideUser = statusOverrideUser;
	}

	public String getFormattedStartDate() {
		return DateUtil2.INSTANCE.formatDate(DateUtil2.DEFAULT_PATTERN, startDate);
	}

	public String getFormattedEndDate() {
		return DateUtil2.INSTANCE.formatDate(DateUtil2.DEFAULT_PATTERN, endDate);
	}

	/**
	 * @return the prc
	 */
	public String getPrc() {
		return prc;
	}

	/**
	 * @param prc
	 *            the prc to set
	 */
	public void setPrc(String prc) {
		this.prc = prc;
	}

	/**
	 * @return the message
	 */
	public String getMessage() {
		return message;
	}

	        /**
     * @param message
     *            the message to set
     */
    public void setMessage(String message) {
        this.message = message;
    }

    public String getModificationDocumentLocation() {
        return modificationDocumentLocation;
    }

    public void setModificationDocumentLocation(String modificationDocumentLocation) {
        this.modificationDocumentLocation = modificationDocumentLocation;
    }

    public String getPrevStartDate() {
        return prevStartDate;
    }

    public void setPrevStartDate(String prevStartDate) {
        this.prevStartDate = prevStartDate;
    }

    public String getPrevEndDate() {
        return prevEndDate;
    }

    public void setPrevEndDate(String prevEndDate) {
        this.prevEndDate = prevEndDate;
    }

    public Integer getPrevStatusId() {
        return prevStatusId;
    }

    public void setPrevStatusId(Integer prevStatusId) {
        this.prevStatusId = prevStatusId;
    }

    public BigDecimal getPrevDirectFunds() {
        return prevDirectFunds;
    }

    public void setPrevDirectFunds(BigDecimal prevDirectFunds) {
        this.prevDirectFunds = prevDirectFunds;
    }

    public BigDecimal getPrevIndirectFunds() {
        return prevIndirectFunds;
    }

    public void setPrevIndirectFunds(BigDecimal prevIndirectFunds) {
        this.prevIndirectFunds = prevIndirectFunds;
    }

}